<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .con {
            width: 800px;
            height: 20px;
            border: 1px solid #ccc;
            position: relative;
        }

        #box {
            background: red;
            height: 20px;
            float: left;
        }

        #num {
            position: absolute;
            transform: translateY(-50%);
            top: 50%;
            left: 5px;
        }
    </style>
</head>

<body>
    <div class="con">
        <div id="box" style="width:0px"></div>
        <span id="num">0%</span>
    </div>

    <script>
        var timer = setInterval(function () {
            var style = parseInt(box.style.width);
            var curStyle = style + 10;
            if (curStyle >= 800) {
                curStyle = 800;
                clearInterval(timer);
            }
            box.style.width = curStyle + 'px';
            num.style.left = curStyle + 2 + 'px';
            num.innerHTML = ((curStyle / 800) * 100).toFixed(2) + '%';
        }, 100)


    </script>
</body>

</html>